package org.qloudgen.borg.thread;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.qloudgen.borg.messaging.HornetqJmsClient;

public class Controller extends Thread{

	private String queueName;
		
	static Log log = LogFactory.getLog(Controller.class);
	
	public Controller(String queueName){
		this.setQueueName(queueName);
	}
	
	@Override
	public void run(){
		
		HornetqJmsClient client = new HornetqJmsClient(queueName);   
        
		client.generateConsumer();
		while (true){
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				log.error(e.getMessage());
				client.close();
			}
		}
		
	}
	
	public void setQueueName(String queueName) {
		this.queueName = queueName;
	}

	public String getQueueName() {
		return queueName;
	}
	
}
